<div class="box-tools" style="top:10px;">
  <form class="form-inline" id="project—form" action="" method="post" pjax-search="" >
    <div class="form-group">
      <label for="start_date">开始时间</label>
      <input class="form-control timepicker" autocomplete="off" id="start_date" name="start_date"
             value="{:input('post.start_date')}" placeholder="{$Think.lang.start_date}">
    </div>
    <div class="form-group">
      <label for="end_date">结束时间</label>
      <input class="form-control timepicker" autocomplete="off" id="end_date" name="end_date"
             value="{:input('post.end_date')}" placeholder="{$Think.lang.end_date}">
    </div>
    <div class="form-group">
      <label for="project">所属项目</label>
      <select class="form-control" name="project_id" id="project" style="border-radius:3px;width:200px;">
          <option value="0">全部</option>
          {volist name="project_list" id="vo"}
          <option value="{$vo.id}"   {if condition=" $vo.id eq input('post.project_id') "} selected="selected" {/if}>{$vo.project_name}</option>
          {/volist}
      </select>
    </div>
    <div class="form-group">
      <input type="submit" class="btn btn-primary ">
      <button type="button" id="dwonload" class="btn btn-primary">下载</button>
      <button type="button" class="btn btn-primary" onclick="resetForm()">重置</button>
    </div>
  </form>
</div>
<script>
    $(function () {
        $('#dwonload').click(function () {
            var url = "{:url('Money/detailForVote')}";
            var project_id = $("select[name='project_id']").val();
            var start_date = $("input[name='start_date']").val();
            var end_date = $("input[name='end_date']").val();
            location.href = url + "?project_id=" + project_id + "&start_date=" + start_date + "&end_date=" + end_date + "&down=1";
        });
        let start_date = $('#start_date').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        });
        let end_date = $('#end_date').datetimepicker({
            format: 'YYYY-MM-DD',
            locale: moment.locale('zh-cn')
        });
        //动态设置最小值
        start_date.on('dp.change', function (e) {
           let initEndDate = $('#end_date').val()
            end_date.data('DateTimePicker').minDate(e.date);
            if(initEndDate === ''){
              $('#end_date').val('')
            }
        });
        //动态设置最大值
        end_date.on('dp.change', function (e) {
            start_date.data('DateTimePicker').maxDate(e.date);
        });
    })

    function resetForm() {
        $('select[name="project_id"]').val('0')
        $('input[name="start_date"]').val('')
        $('input[name="end_date"]').val('')
        $('#project—form').submit()
    }
</script>